package city.spring.modules.consumptionItem.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 实体类：收费项目
 *
 * @author pxm
 * @date 2020-08-05 16:18:33
 */
@Data
@TableName("consumption_items")
@AllArgsConstructor
@NoArgsConstructor
public class ConsumptionItemsEntity implements Serializable {

    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    /**
     * 项目名称
     */
    private String name;

    /**
     * 所属类别
     */
    private String categoryId;
    @TableField(exist = false)
    private String categoryName;

    /**
     * 收费方式
     */
    private String chargeWay;

    /**
     * 项目费用
     */
    private BigDecimal cost;

    /**
     * 所需时间
     */
    private Integer timeNeed;

    /**
     * 是否为房间
     */
    private String isRoom;

    /**
     * 项目简介
     */
    private String describes;

    /**
     * 生效日期
     */
    private Date effectiveDate;

    /**
     * 任务类型（一般/关键）
     */
    private String type;
    /**
     * 执行频率（月/周/天）
     */
    private String frequency;

    /**
     * 执行日期
     */
    private String executionDate;

    /**
     * 优惠比例
     */
    private Double discountRatio;

    /**
     * 优惠生效日期
     */
    private Date discountStartDate;

    /**
     * 优惠失效日期
     */
    private Date discountEndDate;

    /**
     * 优惠金额
     */
    private BigDecimal discountMoeny;

    /**
     * 折后金额
     */
    private BigDecimal afterDiscount;

    /**
     * 优惠月数
     */
    private Integer discountMonths;

    /**
     * 执行时间
     */
    private String executionTime;
    /**
     * 创建时间
     */
    private LocalDateTime gmtCreate;

    @TableField(exist = false)
    private List<ConsumptionItemsEntity> children;

    /**
     * 修改时间
     */
    private LocalDateTime gmtModified;

    public Set<String> getExecutionDateSet() {
        return StringUtils.commaDelimitedListToSet(executionDate);
    }

    public void setExecutionDateSet(List<String> list) {
        this.executionDate = String.join(",", list);
    }

    public void setExecutionDate(String executionDate) {
        this.executionDate = executionDate;
    }

    public void setExecutionDate(List<String> list) {
        this.executionDate = String.join(",", list);
    }

    public Set<String> getExecutionTimeSet() {
        return StringUtils.commaDelimitedListToSet(executionTime);
    }

    public void setExecutionTimeSet(List<String> list) {
        this.executionTime = String.join(",", list);
    }

    public void setExecutionTime(String executionTime) {
        this.executionTime = executionTime;
    }

    public void setExecutionTime(List<String> list) {
        this.executionTime = String.join(",", list);
    }


}